<html>
<head><meta charset="utf-8"><title>Global Hooks · project-error-handling · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/index.html">project-error-handling</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Global.20Hooks.html">Global Hooks</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="212082124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Global%20Hooks/near/212082124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sean Chen (he/him) <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Global.20Hooks.html#212082124">(Oct 02 2020 at 14:32)</a>:</h4>
<p>Is there a good explanation of what global hooks are and how they're used to implement error handling behavior?</p>



<a name="212091489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Global%20Hooks/near/212091489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Ellis O&#x27;Riley Jr. <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Global.20Hooks.html#212091489">(Oct 02 2020 at 15:39)</a>:</h4>
<p>That would be nice to know</p>



<a name="212128612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Global%20Hooks/near/212128612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Global.20Hooks.html#212128612">(Oct 02 2020 at 21:02)</a>:</h4>
<p>I think the closest thing might be the description of how <code>#[panic_handler]</code> works, or possibly the extern existential types RFC</p>



<a name="212128616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Global%20Hooks/near/212128616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Global.20Hooks.html#212128616">(Oct 02 2020 at 21:02)</a>:</h4>
<p>let me link those rq</p>



<a name="212128677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Global%20Hooks/near/212128677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Global.20Hooks.html#212128677">(Oct 02 2020 at 21:03)</a>:</h4>
<p><a href="https://rustc-dev-guide.rust-lang.org/panic-implementation.html?highlight=panic_handler#panicking-in-rust">https://rustc-dev-guide.rust-lang.org/panic-implementation.html?highlight=panic_handler#panicking-in-rust</a></p>



<a name="212128698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Global%20Hooks/near/212128698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Global.20Hooks.html#212128698">(Oct 02 2020 at 21:03)</a>:</h4>
<p><a href="https://github.com/Ericson2314/rust-rfcs/blob/extern-existential-type/text/0000-extern-existential-type.md">https://github.com/Ericson2314/rust-rfcs/blob/extern-existential-type/text/0000-extern-existential-type.md</a></p>



<a name="212128721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Global%20Hooks/near/212128721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Global.20Hooks.html#212128721">(Oct 02 2020 at 21:03)</a>:</h4>
<p>to my knowledge though hooks aren't really a formal concept in rust</p>



<a name="212128730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Global%20Hooks/near/212128730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Global.20Hooks.html#212128730">(Oct 02 2020 at 21:03)</a>:</h4>
<p>they're mostly a hack</p>



<a name="212128801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Global%20Hooks/near/212128801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Global.20Hooks.html#212128801">(Oct 02 2020 at 21:04)</a>:</h4>
<p>and when ppl talk about hooks there are different kinds</p>



<a name="212128819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Global%20Hooks/near/212128819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Global.20Hooks.html#212128819">(Oct 02 2020 at 21:04)</a>:</h4>
<p>like theres <code>#[panic_handler]</code> which is a language item hook</p>



<a name="212128864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Global%20Hooks/near/212128864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Global.20Hooks.html#212128864">(Oct 02 2020 at 21:04)</a>:</h4>
<p>and as far as I know its essentially just an extern function where the compiler handles making sure the definitions resolve to the right symbols via the attribute</p>



<a name="212128887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Global%20Hooks/near/212128887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Global.20Hooks.html#212128887">(Oct 02 2020 at 21:05)</a>:</h4>
<p>but you're essentially just declaring a function in one compilation unit then defining it in another</p>



<a name="212128908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Global%20Hooks/near/212128908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Global.20Hooks.html#212128908">(Oct 02 2020 at 21:05)</a>:</h4>
<p>and if two crates define that same symbol then you cant link them together</p>



<a name="212128939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Global%20Hooks/near/212128939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Global.20Hooks.html#212128939">(Oct 02 2020 at 21:05)</a>:</h4>
<p>then theres the hook from <code>std::panic::set_hook</code></p>



<a name="212129010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Global%20Hooks/near/212129010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Global.20Hooks.html#212129010">(Oct 02 2020 at 21:06)</a>:</h4>
<p>which is different, because unlike the <code>#[panic_handler]</code>, which is static, this can be set at runtime</p>



<a name="212129027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Global%20Hooks/near/212129027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Global.20Hooks.html#212129027">(Oct 02 2020 at 21:06)</a>:</h4>
<p>and it is ultimately built ontop of <code>#[panic_handler]</code></p>



<a name="212129061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Global%20Hooks/near/212129061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Global.20Hooks.html#212129061">(Oct 02 2020 at 21:06)</a>:</h4>
<p>and this is how the standard library lets applications customize panic behaviour while still having default panic handler behaviour</p>



<a name="212142317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Global%20Hooks/near/212142317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Global.20Hooks.html#212142317">(Oct 03 2020 at 00:01)</a>:</h4>
<p><code>alloc_error_handler</code> is another global hook</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>